
<script language="javascript">
	$(document).ready(function(){

		//设置modal垂直居中,移动
		modalSetting(".modal"); 
		
		$('a[data-toggle="tab"]').on('show.bs.tab',function(e){
			if($(e.target).attr("href")=='#future'){
				$("#btn_future2sale").show();
			}else{
				$("#btn_future2sale").hide();
			}
		})
	})
	
</script>


<div id="main">
<!--搜索框开始-->
<div class="row clearfix" id="search-box" style="display:none;margin-top:0">
    <div class="col-md-12 text-right">
        <div>
            <form class="form-inline" role="form">
				<div class="form-group">
					<div class="col-md-2">
						<select name="" id="" class="form-control" v-model="saler_id" @change="changeSaler()">
							<option value="0">选择业务员</option>
							<option :value="salernameItem.id" v-for="(salernameItem,salernameIndex) in salername">{{salernameItem.nickname}}</option>
						</select>
					</div>
				</div>
                <div class="form-group">
                    <label for="name">搜索内容</label>
                    <input type="text" class="form-control" id="searchText" placeholder="请输入公司名或订单号">
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-primary" @click="searchText_()"><span class="glyphicon glyphicon-search"></span> 查找</button>
                </div>
            </form>
         </div>
    </div>
</div>

<!--搜索框结束-->
<div class="container-fluid">

	<div class="row clearfix">
		<div class="col-md-12 column" id="mainList">
			<div class="alert alert-dismissable alert-info">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
				<p></p>
			</div>
		</div>
	</div>
   
   <input type="hidden"  id="isshow" value="{$isshow}">
   <input type="hidden"  id="admin_name" value="{$Request.session.admin.nickname}">
	<div class="ntDesktop">
		{if $isshow == 1}
  			<div class="ntDesktop-head">销售订单列表</div>
  		{/if}
		<div class="row">
			<div class="col-md-7">
				<ul class="nav nav-tabs">
                  	<li v-if="isshow_search" class="active">
                      	<a href="#home" data-toggle="tab" class="ptlang">搜索结果
                      		<span class="label label-info" v-if="list.length > 0">{{list.length}}</span>
                      		<span class="glyphicon glyphicon-remove shdow" style="margin-left: 10px;" @click="shdow()"></span>
                      	</a>
                  	</li>
					<li :class="{'active':!isshow_search}" @click="tabJump('all')">
						<a href="#all" data-toggle="tab">全部 <span class="label label-info" v-if="typeNum.allNum > 0">{{typeNum.allNum}}</span></a>
					</li>
					<li @click="tabJump('new')">
						<a href="#new" data-toggle="tab">新订单 <span class="label label-info" v-if="typeNum.newNum > 0">{{typeNum.newNum}}</span></a>
					</li>
					<li @click="tabJump('makeId')">
						<a href="#make" data-toggle="tab">配货中 <span class="label label-info" v-if="typeNum.makeIdNum > 0">{{typeNum.makeIdNum}}</span></a>
					</li>
					<li @click="tabJump('needPay')">
						<a href="#unpay" data-toggle="tab">待付款 <span class="label label-info" v-if="typeNum.needPayNum > 0">{{typeNum.needPayNum}}</span></a>
					</li>
					<li @click="tabJump('delivery')">
						<a href="#undelivery" data-toggle="tab">待发货 <span class="label label-info" v-if="typeNum.deliveryNum > 0">{{typeNum.deliveryNum}}</span></a>
					</li>
					<li @click="tabJump('receive')">
						<a href="#receive" data-toggle="tab">已送货 <span class="label label-info" v-if="typeNum.receiveNum > 0">{{typeNum.receiveNum}}</span></a>
					</li>
					<li @click="tabJump('finish')">
						<a href="#finish" data-toggle="tab">已完成 <span class="label label-info" v-if="typeNum.finishNum > 0">{{typeNum.finishNum}}</span></a>
					</li>
					<!-- <li>
						<a href="#commision" data-toggle="tab">+ 提成</a>
					</li> -->
					<li @click="tabJump('future')">
						<a href="#future" data-toggle="tab">期货 <span class="label label-info" v-if="typeNum.futureNum > 0">{{typeNum.futureNum}}</span></a>
					</li>
					<li @click="tabJump('del')">
						<a href="#del" data-toggle="tab">删除 <span class="label label-info" v-if="typeNum.delNum > 0">{{typeNum.delNum}}</span></a>
					</li>
				</ul>
			</div>
			{if $isshow == 1}
			<div class="col-md-3 text-right" >
				<button class="btn btn-checkbox btn-default" @click="underwrite_()">
					<input type="checkbox" > 只显示包销订单
				</button>
			</div>
			
			<div class="col-md-2 text-right">
				<button type="button" id="btn_future2sale" class="btn btn-primary" style="display: none">生成销售订单</button>
				<a href="{:url('sale/saleAdd')}" class="btn btn-primary" v-if="auth_ids.indexOf(294) != -1" @click="setStorage()"  target="_blank">
					<span class="fa fa-plus"> 添加新订单</span>
				</a>
			</div>
			{/if}
		</div>

		<div class="row">
			<div class="col-md-12 tab-content">

				<!-- 全部订单显示   -->
				<div id="all" class="tab-pane active">
					<table class="table table-striped table-hover ntTable">
						<thead>
							<tr>
								<th>ID</th>
								<th class="sorting">优先</th>
								<th class="sorting">状态</th>
								<th class="sorting">客户</th>
								<th class="sorting">金额</th>
								<th class="sorting">费用</th>
								<th class="sorting">应付/已付</th>
								<th class="sorting">业务员</th>
								<th>创建/编辑</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(listItem,listIndex) in list">
								<td>
									{{formatUnit(listItem.id,'id')}}<br>
									<!-- <a href="delivery_note.detail.html" target="_blank">{{listItem.delivery_note_id ? formatUnit(listItem.delivery_note_id,'id') : ''}}</a> -->
								</td>
								<td align="center">
									<span class="label label-warning">{{listItem.priority}}</span>
								</td>
								<td  style="text-align: center;">
									<span v-if="listItem.status == 1" class="text-danger">确认中</span> 
									<span v-if="listItem.status == 2 && listItem.underwrite == 0">定金</span> 
									<span v-if="listItem.status == 3 && listItem.underwrite == 0">排队中</span> 
									<span v-if="listItem.status == 4 && listItem.underwrite == 0">配货中</span> 
									<span v-if="listItem.status == 5">待付款</span> 
									<span v-if="listItem.status == 6 && listItem.underwrite == 0">待发货</span> 
									<span v-if="listItem.status == 7 && listItem.underwrite == 0">送货中</span> 
									<span v-if="listItem.status == 8 && listItem.underwrite == 0">已送货</span> 
									<span v-if="listItem.status == 9">完成</span> 
									<span v-if="listItem.status != 1 && listItem.status != 5 && listItem.status != 9 && listItem.underwrite == 1">-</span> 
									<span v-if="listItem.lockStatus == 1"><br><span class="label label-danger">解锁</span></span>
								</td>
								<td>
									<a :href="'/admin/customer/companycheck?company_id='+listItem.co_id+'&tab=detail'" target="_blank">{{listItem.company_name}}</a><br>
									<!-- <span class="label label-primary" v-if="listItem.underwrite == 1">DELIVERY(送货单)</span> -->
									<span class="label label-primary" v-if="listItem.underwrite == 1">UW</span>
									<span class="label label-warning" v-if="listItem.pledge == 1">PLEDGE</span>
									<span class="label label-warning" v-if="listItem.makefirst == 1">FM</span>
									<span class="label label-danger" v-if="listItem.lowprice > 0">LOW</span>
									<span class="label label-danger" v-if="listItem.zeroprice == 1">ZERO</span>
									<span class="label label-info">{{listItem.branchcompany_name}}</span>
								</td>
								<td align="right">{{formatUnit(listItem.total,'BRL')}} <small class="unit">BRL</small></td>
								<td align="right">{{formatUnit(listItem.cost,'BRL')}}<small class="unit">BRL</small></td>
								<td align="right">
									<span class="text-primary">{{formatUnit(listItem.pay,'BRL')}}</span> <small class="unit">BRL</small><br>
									<span class="text-primary">{{formatUnit(listItem.paid,'BRL')}}</span> <small class="unit">BRL</small>
								</td>
								<td>{{listItem.saler_name}}</td>
								<td>
									{{listItem.create_name}}<small> / {{listItem.create_time}}</small><br>
									{{listItem.update_name}}<small> {{listItem.update_time ?  ' / ' + listItem.update_time : ''}}</small>
								</td>
								<td class="text-right">
									<a :href="'/admin/sale/checkDetail?id='+listItem.id" class="btn btn-sm btn-primary" target="_blank">查看</a>
									<!-- <a :href="'/admin/sale/saleEdit?id='+listItem.id" class="btn btn-sm btn-primary" v-if="listItem.status != 4">编辑</a> -->
									<a :href="'/admin/sale/saleEdit?id='+listItem.id" class="btn btn-sm btn-primary" v-if="saleStatusStr.indexOf(listItem.status) == -1 && auth_ids.indexOf(234) != -1" @click="setStorage()"  target="_blank">编辑</a>
									<a :href="'/admin/sale/saleEdit?id='+listItem.id+'&tab=paid'" class="btn btn-sm btn-default" v-if="listItem.status != 4 || listItem.status != 9 && auth_ids.indexOf(234) != -1"  target="_blank">付款登记</a>
									<a :href="'/admin/sale/deliveryNoteList?id='+listItem.id+'&viewType=add'" class="btn btn-sm btn-warning" v-if="listItem.underwrite==1 && listItem.zeroprice != 1">送货单</a>
									<div class="btn-group">
										<button class="btn btn-sm btn-default" type="button"> 更多 </button>
										<button class="btn btn-sm btn-default dropdown-toggle" type="button" data-toggle="dropdown">
											<span class="caret"></span>
										</button>
										<ul class="dropdown-menu pull-right" role="menu">
											<li><a href="print.html" @click="print(listItem.id)" v-if="auth_ids.indexOf(393) != -1">打印</a></li>
											<li><a href="#" data-toggle="modal" data-target="#sale_remarkModal" @click="saleRemark(listItem.id,'get',listItem.receive_at)" v-if="auth_ids.indexOf(392) != -1">备注</a></li>
											<li><a v-if="listItem.status != 4 && auth_ids.indexOf(295) != -1" @click="dataDel(listIndex,listItem.id,'sale')"  :disabled="isdisabled">删除</a></li>
										</ul>
									</div>
								</td>
							</tr>
                            <tr style="text-align: center;" v-if="list.length == 0">
                                <td colspan="10" class="no_date" style="line-height: 20rem">{:lang('no_data')} </td>
                            </tr>
						</tbody>
					</table>
					
				</div>
				
				<!-- 提成 订单显示 -->
				<div id="commision" class="tab-pane">
					<table class="table table-striped table-hover ntTable">
						<thead>
							<tr>
								<th>ID</th>
								<th class="sorting">优先</th>
								<th class="sorting">状态</th>
								<th class="sorting">客户</th>
								<th class="sorting">金额</th>
								<th class="sorting">费用</th>
								<th class="sorting">应付/已付</th>
								<th class="sorting">提成</th>
								<th class="sorting">业务员</th>
								<th>创建/编辑</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>
									<a href="detail.html">8882</a>
								</td>
								<td align="center">
									<span class="label label-primary">5</span>
								</td>
								<td>完成</td>
								<td>
									<a href="company.detail">PAPIROS COMERCIO DE INFORMATICA LTDA ME</a><br>
								</td>
								<td align="right">5000.00 <small class="unit">BRL</small></td>
								<td align="right">200.00 <small class="unit">BRL</small></td>
								<td align="right">
									<span class="text-primary">5200.00</span> <small class="unit">BRL</small><br>
									- <small class="unit">BRL</small>
								</td>
								<td align="right">200.00<small class="unit">BRL</small></td>
								<td>MEDEIROS</td>
								<td>
									PAULO<small> / 25-11-2019 11:25:30</small><br>
									PAULO<small> / 25-11-2019 11:25:30</small>
								</td>
								<td class="text-right">
									<a href="add.html" class="btn btn-sm btn-primary">查看</a>
									<button type="button" class="btn btn-sm btn-default" data-toggle="modal" data-target="#sale_remarkModal">备注</button>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				
				<!-- 期货 订单显示 -->
				<div id="future" class="tab-pane">
					<table class="table table-striped table-hover ntTable">
						<thead>
							<tr>
								<th><input type="checkbox" name="ids"></th>
								<th>ID</th>
								<th class="sorting">客户</th>
								<th class="sorting">产品</th>
								<th class="sorting">金额</th>
								<th class="sorting">业务员</th>
								<th>创建</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(listItem1,listIndex1) in list">
								<td><input type="checkbox" name="ids" :value="listItem1.id"></td>
								<td>
									<a href="future.detail.html" target="_blank">{{formatUnit(listItem1.id,'id')}}</a><br>
								</td>
								<td>
									<a href="company.detail">{{listItem1.company_name}}</a><br>
									<span class="label label-info">{{listItem1.branchcompany_name}}</span>
								</td>
								<td align="right">{{listItem1.qty}} <small class="unit">ITEM</small></td>
								<td align="right">{{listItem1.qty * listItem1.price}} <small class="unit">BRL</small></td>
								<td>{{listItem1.saler_name}}</td>
								<td>
									{{listItem1.create_name}}<br><small> {{listItem1.create_time}}</small>
								</td>
								<td class="text-right">
									<button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#future_viewModal" @click="checkFuture(listIndex1)"  target="_blank">查看</button>
									<a href="#" class="btn btn-sm btn-default" @click="dataDel(listIndex1,listItem1.id,'future')" v-if="auth_ids.indexOf(295) != -1">删除</a>
								</td>
							</tr>
                            <tr style="text-align: center;" v-if="list.length == 0">
                                <td colspan="8" class="no_date" style="line-height: 20rem">{:lang('no_data')} </td>
                            </tr>
						</tbody>
					</table>
				</div>

				<!--分页-->
                <ul class="pagination" id="pagination" v-show="list.length!=0"></ul>
			</div>
		</div>



	</div>
</div>

<!-- 订单备注 弹窗部分-->
<div class="modal fade" id="sale_remarkModal" tabindex="-1" role="dialog" aria-labelledby="ntModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="ntModalLabel">订单({{ formatUnit(sale_id,'id') }})备注</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-dismissable alert-info">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            <h4> 信息框 </h4>
                            送货完成后，送货完成之前的备注不能编辑和删除<br>
                            <p></p>
                        </div>
                    </div>
                </div>
				<div class="row">
                    <div class="col-md-4">
						<button class="btn btn-checkbox" @click="remarkPrivate_">
							<input type="checkbox" id="remarkPrivate_"> 私有
						</button>
					</div>
					<div class="col-md-8">
						<div class="input-group">
							<input type="text" class="form-control" v-model="addRemarkText">
							<input type="hidden" id="addRemarkTextType" value="-1">
							<div class="input-group-btn">
								<button class="btn btn-primary" @click="addRemark()">保存</button>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
                    <div class="col-md-12">
                        <table class="table table-hover ntTable">
							<thead>
								<tr>
									<td>No.</td>
									<td style="min-width: 30vw">内容</td>
									<td>私有</td>
									<td>编辑</td>
									<td>操作</td>
								</tr>
							</thead>
                            <tbody>
								<tr v-for="(saleRemarkDataItem,saleRemarkDataIndex) in saleRemarkData">
									<td align="center">{{saleRemarkDataIndex + 1}}</td>
									<td>{{saleRemarkDataItem.remark}}</td>
									<td>{{ saleRemarkDataItem.private ? 'O' : '-' }}</td>
									<td>{{ saleRemarkDataItem.update_name ? saleRemarkDataItem.update_name + ' / ' + saleRemarkDataItem.update_time : ''}}</td>
									<td align="right">
										<button class="btn btn-sm btn-primary" @click="remarkOption(saleRemarkDataIndex,'edit')" v-if="receive_at == 0 ||  saleRemarkDataItem.update_at > receive_at" target="_blank">编辑</button>
										<button class="btn btn-sm btn-default" @click="remarkOption(saleRemarkDataIndex,'del')">删除</button>
									</td>
								</tr>
							</tbody>
                        </table>
                    </div>
                </div>
			</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>取消</button>
                <button type="button" class="btn btn-primary" style="padding-left:24px;padding-right:24px" @click="saleRemark('','save')">
                	<span class="glyphicon glyphicon-floppy-disk"></span>保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 期货订单详情 -->
<div class="modal fade" id="future_viewModal" tabindex="-1" role="dialog" aria-labelledby="ntModalLabel2" aria-hidden="true">
    <div class="modal-dialog modal-lg" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="ntModalLabel2">期货({{formatUnit(futureInfo.id,'id')}})详情</h4>
            </div>
            <div class="modal-body">
				<div class="row">
                    <div class="col-md-1">
						公司
					</div>
					<div class="col-md-11">
						{{futureInfo.company_name}} {{futureInfo.branchcompany_name ?  ' / '+futureInfo.branchcompany_name:''}}
					</div>
				</div>
				<div class="row">
                    <div class="col-md-12">
						<div class="div-scroll" style="max-height: 40vh">
							<table class="table table-hover ntTable">
								<thead>
									<tr>
										<td>No.</td>
										<td style="min-width: 30vw">产品</td>
										<td>数量</td>
										<td>金额</td>
										<td>编辑</td>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td align="center">{{formatUnit(futureInfo.id,'id')}}</td>
										<td>
											<div class="pro">
												<div class="pro-icon"><img :src="futureInfo.img_url" border="0" width="48px" height="48px" alt="ICON"></div>
												<div class="pro-name">
													<small>{{formatUnit(futureInfo.id,'id')}} {{futureInfo.brand_name ? ' / ' + futureInfo.brand_name : ''}} {{futureInfo.model ? ' / ' + futureInfo.model : ''}} </small> <br />{{futureInfo.pro_name}}{{futureInfo.model}}
												</div>
											</div>
										</td>
										<td align="right">{{futureInfo.price}}<small class="unit">PCS</small></td>
										<td align="right">{{futureInfo.ctn}}<small class="unit">BRL</small></td>
										<td>{{futureInfo.create_time}}<br> <small>{{futureInfo.create_name}}</small></td>
									</tr>
								</tbody>
							</table>
						</div>
                    </div>
                </div>
			</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>取消</button>
            </div>
        </div>
    </div>
</div>

</div>
<script type="text/javascript">
	$('.loding').hide()
</script>
<script src="/static/Admin/js/sale.js"></script>

{include file="public/foot"/}